package com.ilomed;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.ilomed.model.Goal;
import com.ilomed.service.GoalService;

@Component
@Path("/hello")
@Scope("request")
public class Hello {
	
  @Autowired
  private GoalService goalService;
  
  @GET
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public List<Todo> getBasicData() throws Exception {
	  Todo todo = new Todo("1", "Learn REST");
	  todo.setDescription("Read http://www.vogella.com/tutorials/REST/article.html");
	  List<Todo> l = new ArrayList<Todo>();
	  l.add(todo);
      return l;
  }
  
  @GET
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  @Path("/path")
  public List<Goal> getAllGoals() throws Exception {
	  List<Goal> goals = goalService.findAll();
	  return goals;
  }
  
} 
